<?php

namespace app\index\model;

use think\Model;

class NavList extends Model
{
    public function getImageAttr($value)
    {
        return $value ? 'http://lclook.oss-cn-shenzhen.aliyuncs.com'.$value : 'http://lclook.oss-cn-shenzhen.aliyuncs.com/uploads/20210122/9c2cb54d989e366329d68d595715daaf.png';
    }


    public function getCreateTimeAttr($value)
    {
        return $value ? date('Y-m-d', $value) : '';
    }

    public static function getLists($navId, $size = 20)
    {
        return self::where('nav_id', $navId)->where('onlineswitch', 1)->order('weigh desc')->paginate($size);
    }

    public static function getByNavId($navId)
    {
        return self::where('nav_id', $navId)->where('onlineswitch', 1)->order('weigh desc')->limit(5)->select();
    }

}
